package com.jsy.search.controller;

import com.jsy.common.vo.Result;
import com.jsy.search.service.SkuEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/sku/es")
public class SkuEsController{

    @Autowired
    private SkuEsService skuEsService;

    /**
     * 导入sku商品数据到es
     * @return
     */
    @GetMapping("/import")
    public Result importSku(){
        skuEsService.importSku();
        return new Result("导入数据到索引库成功！");
    }

    /**
     * 根据搜索条件搜索商品数据
     * @param searchMap 搜索条件
     * @return
     */
    @GetMapping
    public Map search(@RequestParam(required = false) Map<String,String> searchMap){
        return skuEsService.search(searchMap);

    }
}
